package cn.com.wdjedu.androidapp.wjeduandroid.support.lib.mvputils;

import java.io.IOException;

import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 添加固定三个参数的拦截器
 */
public class AddQueryParameterInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request originalRequest = chain.request();
        Request request;
        String method = originalRequest.method();
        Headers headers = originalRequest.headers();
        HttpUrl.Builder builder = originalRequest.url().newBuilder();
//        if (GlobalContext.getInstance().getLoginInfo() != null) {
//            builder.addQueryParameter("appkey", GlobalContext.getInstance().getLoginInfo().getData().getAppKey());
//        }
        HttpUrl modifiedUrl = builder.build();
        request = originalRequest.newBuilder().url(modifiedUrl).build();
        return chain.proceed(request);
    }
}
